package com.example.springcloud.service;

import com.example.springcloud.pojo.Dept;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * @author :lihao
 * @date :2020/11/30
 * @description :value为服务名称
 */
@Component
@FeignClient(value = "SPRINGCLOUD-PROVIDER-DEPT", fallbackFactory = DeptClientServiceFallbackFactory.class)
public interface DeptClientService {

    /**
     * 通过id查部门
     * @param id 部门id
     * @return 部门信息
     */
    @GetMapping("/dept/get/{id}")
    Dept queryDeptById(@PathVariable("id") Long id);

    /**
     * 添加一个部门
     * @param dept 部门实体
     * @return 添加结果
     */
    @PostMapping("/dept/add")
    boolean addDepartment(Dept dept);

    /**
     * 查询所有部门
     * @return 部门列表
     */
    @GetMapping("/dept/list")
    List<Dept> queryAllDept();

}
